package org.hy.xflow.engine.junit;

import java.util.ArrayList;
import java.util.List;

import org.hy.common.xml.XJSON;
import org.hy.common.xml.log.Logger;
import org.hy.xflow.engine.bean.FlowData;
import org.hy.xflow.engine.bean.NextRoutes;
import org.hy.xflow.engine.bean.UserParticipant;
import org.hy.xflow.engine.enums.ParticipantTypeEnum;
import org.junit.Test;





public class JU_Json
{
    
    private static final Logger $Logger = new Logger(JU_Json.class ,true);
    
    
    
    @Test
    public void test_JavaToJson_20240509() throws Exception
    {
        FlowData              v_FlowData = new FlowData();
        List<UserParticipant> v_Users    = new ArrayList<UserParticipant>();
        UserParticipant       v_User     = new UserParticipant();
        XJSON                 v_XJson    = new XJSON();
        
        v_User.setObjectTypeEnum(ParticipantTypeEnum.$Role);
        v_Users.add(v_User);
        v_FlowData.setParticipants(v_Users);
        
        System.out.println(v_XJson.toJson(v_FlowData).toJSONString());
    }
    
    
    
    @Test
    public void test_JsonToJava_20220331() throws Exception
    {
        XJSON      v_XJson   = new XJSON();
        String     v_JsonStr = "";
        NextRoutes v_Object = null;
        
        v_JsonStr = "{\r\n"
                + "    \"body\":\r\n"
                + "    {\r\n"
                + "        \"currentActivity\":\r\n"
                + "        {\r\n"
                + "            \"activityCode\": \"汇总结果\",\r\n"
                + "            \"activityID\": \"A-ManyRoute-004\",\r\n"
                + "            \"activityName\": \"汇总结果\",\r\n"
                + "            \"activityType\":\r\n"
                + "            {\r\n"
                + "                \"activityType\": \"常规\",\r\n"
                + "                \"activityTypeID\": \"AT001\",\r\n"
                + "                \"infoComment\": \"\",\r\n"
                + "                \"orderNo\": \"\"\r\n"
                + "            },\r\n"
                + "            \"activityTypeID\": \"\",\r\n"
                + "            \"backgroudColor\": \"\",\r\n"
                + "            \"counterPass\": \"2\",\r\n"
                + "            \"createTime\": \"\",\r\n"
                + "            \"creater\": \"\",\r\n"
                + "            \"createrID\": \"\",\r\n"
                + "            \"flagColor\": \"\",\r\n"
                + "            \"fontColor\": \"\",\r\n"
                + "            \"height\": \"\",\r\n"
                + "            \"iconURL\": \"\",\r\n"
                + "            \"infoComment\": \"\",\r\n"
                + "            \"lastTime\": \"\",\r\n"
                + "            \"lastUser\": \"\",\r\n"
                + "            \"lastUserID\": \"\",\r\n"
                + "            \"lineColor\": \"\",\r\n"
                + "            \"participantByActivitys\": \"\",\r\n"
                + "            \"participantByCreater\": \"\",\r\n"
                + "            \"participants\": \"\",\r\n"
                + "            \"passType\": \"OR\",\r\n"
                + "            \"routes\": \"\",\r\n"
                + "            \"summaryPass\": \"100.0\",\r\n"
                + "            \"templateID\": \"T-ManyRoute-001\",\r\n"
                + "            \"width\": \"\",\r\n"
                + "            \"x\": \"\",\r\n"
                + "            \"y\": \"\",\r\n"
                + "            \"z\": \"\"\r\n"
                + "        },\r\n"
                + "        \"currentProcess\":\r\n"
                + "        {\r\n"
                + "            \"counter\": \"2\",\r\n"
                + "            \"counterPass\": \"2\",\r\n"
                + "            \"createOrg\": \"\",\r\n"
                + "            \"createOrgID\": \"\",\r\n"
                + "            \"createTime\": \"2019-09-19 10:57:29\",\r\n"
                + "            \"creater\": \"小明的妈妈\",\r\n"
                + "            \"createrID\": \"Mother-01\",\r\n"
                + "            \"currentActivityCode\": \"汇总结果\",\r\n"
                + "            \"currentActivityID\": \"A-ManyRoute-004\",\r\n"
                + "            \"currentActivityName\": \"汇总结果\",\r\n"
                + "            \"futureParticipants\": \"\",\r\n"
                + "            \"infoComment\": \"\",\r\n"
                + "            \"isPass\": \"1\",\r\n"
                + "            \"limitOrgID\": \"\",\r\n"
                + "            \"limitTime\": \"2000-01-01 00:00:00\",\r\n"
                + "            \"limitUserID\": \"\",\r\n"
                + "            \"nextActivityCode\": \"\",\r\n"
                + "            \"nextActivityID\": \"\",\r\n"
                + "            \"nextActivityName\": \"\",\r\n"
                + "            \"nextProcessID\": \"\",\r\n"
                + "            \"operateDatas\": \"\",\r\n"
                + "            \"operateFiles\": \"\",\r\n"
                + "            \"operateOrg\": \"\",\r\n"
                + "            \"operateOrgID\": \"\",\r\n"
                + "            \"operateTime\": \"2019-09-19 10:57:29\",\r\n"
                + "            \"operateTimeLen\": \"0\",\r\n"
                + "            \"operateType\": \"\",\r\n"
                + "            \"operateTypeID\": \"\",\r\n"
                + "            \"operateUser\": \"小明的妈妈\",\r\n"
                + "            \"operateUserID\": \"Mother-01\",\r\n"
                + "            \"participants\": \"\",\r\n"
                + "            \"passType\": \"\",\r\n"
                + "            \"previousActivityCode\": \"妈妈是否同意\",\r\n"
                + "            \"previousActivityID\": \"A-ManyRoute-003\",\r\n"
                + "            \"previousActivityName\": \"妈妈是否同意\",\r\n"
                + "            \"previousOperateTypeID\": \"RT003\",\r\n"
                + "            \"previousProcessID\": \"XFD52585EAB0004138AAF4E4F3CC61089A\",\r\n"
                + "            \"processID\": \"XFA23D682552DD403B8CD713960BAFDFA7\",\r\n"
                + "            \"processNo\": \"-1\",\r\n"
                + "            \"serviceDataID\": \"能玩游戏吗011\",\r\n"
                + "            \"splitProcessID\": \"XFB0432B54C8D64C2E8BE59CB64F4DC5FF\",\r\n"
                + "            \"summary\": \"100.0\",\r\n"
                + "            \"summaryPass\": \"100.0\",\r\n"
                + "            \"templateID\": \"\",\r\n"
                + "            \"workID\": \"XF860BE5B05F064B8CBDC22F747BF2F757\"\r\n"
                + "        },\r\n"
                + "        \"flow\":\r\n"
                + "        {\r\n"
                + "            \"createOrg\": \"\",\r\n"
                + "            \"createOrgID\": \"\",\r\n"
                + "            \"createTime\": \"2019-09-19 10:54:56\",\r\n"
                + "            \"creater\": \"小明\",\r\n"
                + "            \"createrID\": \"Children-01\",\r\n"
                + "            \"flowTemplateID\": \"T-ManyRoute-001\",\r\n"
                + "            \"isDelete\": \"0\",\r\n"
                + "            \"isValid\": \"1\",\r\n"
                + "            \"lastOrg\": \"\",\r\n"
                + "            \"lastOrgID\": \"\",\r\n"
                + "            \"lastProcessID\": \"XFA23D682552DD403B8CD713960BAFDFA7\",\r\n"
                + "            \"lastTime\": \"2019-09-19 10:57:29\",\r\n"
                + "            \"lastUser\": \"小明的妈妈\",\r\n"
                + "            \"lastUserID\": \"Mother-01\",\r\n"
                + "            \"processes\": \"\",\r\n"
                + "            \"serviceDataID\": \"能玩游戏吗011\",\r\n"
                + "            \"workFatherID\": \"\",\r\n"
                + "            \"workID\": \"XF860BE5B05F064B8CBDC22F747BF2F757\"\r\n"
                + "        },\r\n"
                + "        \"routes\": [\r\n"
                + "        {\r\n"
                + "            \"activity\":\r\n"
                + "            {\r\n"
                + "                \"activityCode\": \"汇总结果\",\r\n"
                + "                \"activityID\": \"A-ManyRoute-004\",\r\n"
                + "                \"activityName\": \"汇总结果\",\r\n"
                + "                \"activityType\":\r\n"
                + "                {\r\n"
                + "                    \"activityType\": \"常规\",\r\n"
                + "                    \"activityTypeID\": \"AT001\",\r\n"
                + "                    \"infoComment\": \"\",\r\n"
                + "                    \"orderNo\": \"\"\r\n"
                + "                },\r\n"
                + "                \"activityTypeID\": \"\",\r\n"
                + "                \"backgroudColor\": \"\",\r\n"
                + "                \"counterPass\": \"2\",\r\n"
                + "                \"createTime\": \"\",\r\n"
                + "                \"creater\": \"\",\r\n"
                + "                \"createrID\": \"\",\r\n"
                + "                \"flagColor\": \"\",\r\n"
                + "                \"fontColor\": \"\",\r\n"
                + "                \"height\": \"\",\r\n"
                + "                \"iconURL\": \"\",\r\n"
                + "                \"infoComment\": \"\",\r\n"
                + "                \"lastTime\": \"\",\r\n"
                + "                \"lastUser\": \"\",\r\n"
                + "                \"lastUserID\": \"\",\r\n"
                + "                \"lineColor\": \"\",\r\n"
                + "                \"participantByActivitys\": \"\",\r\n"
                + "                \"participantByCreater\": \"\",\r\n"
                + "                \"participants\": \"\",\r\n"
                + "                \"passType\": \"OR\",\r\n"
                + "                \"routes\": \"\",\r\n"
                + "                \"summaryPass\": \"100.0\",\r\n"
                + "                \"templateID\": \"T-ManyRoute-001\",\r\n"
                + "                \"width\": \"\",\r\n"
                + "                \"x\": \"\",\r\n"
                + "                \"y\": \"\",\r\n"
                + "                \"z\": \"\"\r\n"
                + "            },\r\n"
                + "            \"activityCode\": \"汇总结果\",\r\n"
                + "            \"activityID\": \"A-ManyRoute-004\",\r\n"
                + "            \"activityRouteCode\": \"执行\",\r\n"
                + "            \"activityRouteID\": \"AR-ManyRoute-004To005\",\r\n"
                + "            \"activityRouteName\": \"执行\",\r\n"
                + "            \"conditionMethod\": \"\",\r\n"
                + "            \"conditionVType\": \"0\",\r\n"
                + "            \"conditionValue\": \"\",\r\n"
                + "            \"conditionXJavaID\": \"\",\r\n"
                + "            \"createTime\": \"2019-09-11 01:01:01\",\r\n"
                + "            \"creater\": \"ZhengWei(HY)\",\r\n"
                + "            \"createrID\": \"UID-00001\",\r\n"
                + "            \"fontColor\": \"#000000\",\r\n"
                + "            \"infoComment\": \"\",\r\n"
                + "            \"lastTime\": \"2019-09-16 15:55:35\",\r\n"
                + "            \"lastUser\": \"ZhengWei(HY)\",\r\n"
                + "            \"lastUserID\": \"UID-00001\",\r\n"
                + "            \"lineColor\": \"#6AB975\",\r\n"
                + "            \"nextActivity\":\r\n"
                + "            {\r\n"
                + "                \"activityCode\": \"执行结果\",\r\n"
                + "                \"activityID\": \"A-ManyRoute-005\",\r\n"
                + "                \"activityName\": \"执行结果\",\r\n"
                + "                \"activityType\":\r\n"
                + "                {\r\n"
                + "                    \"activityType\": \"常规\",\r\n"
                + "                    \"activityTypeID\": \"AT001\",\r\n"
                + "                    \"infoComment\": \"\",\r\n"
                + "                    \"orderNo\": \"\"\r\n"
                + "                },\r\n"
                + "                \"activityTypeID\": \"\",\r\n"
                + "                \"backgroudColor\": \"\",\r\n"
                + "                \"counterPass\": \"0\",\r\n"
                + "                \"createTime\": \"\",\r\n"
                + "                \"creater\": \"\",\r\n"
                + "                \"createrID\": \"\",\r\n"
                + "                \"flagColor\": \"\",\r\n"
                + "                \"fontColor\": \"\",\r\n"
                + "                \"height\": \"\",\r\n"
                + "                \"iconURL\": \"\",\r\n"
                + "                \"infoComment\": \"\",\r\n"
                + "                \"lastTime\": \"\",\r\n"
                + "                \"lastUser\": \"\",\r\n"
                + "                \"lastUserID\": \"\",\r\n"
                + "                \"lineColor\": \"\",\r\n"
                + "                \"participantByActivitys\": \"\",\r\n"
                + "                \"participantByCreater\": \"\",\r\n"
                + "                \"participants\": \"\",\r\n"
                + "                \"passType\": \"\",\r\n"
                + "                \"routes\": \"\",\r\n"
                + "                \"summaryPass\": \"0.0\",\r\n"
                + "                \"templateID\": \"T-ManyRoute-001\",\r\n"
                + "                \"width\": \"\",\r\n"
                + "                \"x\": \"\",\r\n"
                + "                \"y\": \"\",\r\n"
                + "                \"z\": \"\"\r\n"
                + "            },\r\n"
                + "            \"nextActivityCode\": \"执行结果\",\r\n"
                + "            \"nextActivityID\": \"A-ManyRoute-005\",\r\n"
                + "            \"participantByCreater\": \"\",\r\n"
                + "            \"participants\": \"\",\r\n"
                + "            \"routeType\":\r\n"
                + "            {\r\n"
                + "                \"infoComment\": \"\",\r\n"
                + "                \"orderNo\": \"\",\r\n"
                + "                \"routeType\": \"转派\",\r\n"
                + "                \"routeTypeID\": \"RT001\"\r\n"
                + "            },\r\n"
                + "            \"routeTypeID\": \"RT001\",\r\n"
                + "            \"templateID\": \"T-ManyRoute-001\"\r\n"
                + "        }],\r\n"
                + "        \"summarys\": [\r\n"
                + "        {\r\n"
                + "            \"counter\": \"1\",\r\n"
                + "            \"counterPass\": \"2\",\r\n"
                + "            \"createOrg\": \"\",\r\n"
                + "            \"createOrgID\": \"\",\r\n"
                + "            \"createTime\": \"2019-09-19 10:56:39\",\r\n"
                + "            \"creater\": \"小明\",\r\n"
                + "            \"createrID\": \"Children-01\",\r\n"
                + "            \"currentActivityCode\": \"妈妈是否同意\",\r\n"
                + "            \"currentActivityID\": \"A-ManyRoute-003\",\r\n"
                + "            \"currentActivityName\": \"妈妈是否同意\",\r\n"
                + "            \"futureParticipants\": \"\",\r\n"
                + "            \"infoComment\": \"要做完作业才能玩\",\r\n"
                + "            \"isPass\": \"\",\r\n"
                + "            \"limitOrgID\": \"\",\r\n"
                + "            \"limitTime\": \"2000-01-01 00:00:00\",\r\n"
                + "            \"limitUserID\": \"\",\r\n"
                + "            \"nextActivityCode\": \"汇总结果\",\r\n"
                + "            \"nextActivityID\": \"A-ManyRoute-004\",\r\n"
                + "            \"nextActivityName\": \"汇总结果\",\r\n"
                + "            \"nextProcessID\": \"XFA23D682552DD403B8CD713960BAFDFA7\",\r\n"
                + "            \"operateDatas\": \"\",\r\n"
                + "            \"operateFiles\": \"\",\r\n"
                + "            \"operateOrg\": \"\",\r\n"
                + "            \"operateOrgID\": \"\",\r\n"
                + "            \"operateTime\": \"2019-09-19 10:57:29\",\r\n"
                + "            \"operateTimeLen\": \"0\",\r\n"
                + "            \"operateType\": \"汇总\",\r\n"
                + "            \"operateTypeID\": \"RT003\",\r\n"
                + "            \"operateUser\": \"小明的妈妈\",\r\n"
                + "            \"operateUserID\": \"Mother-01\",\r\n"
                + "            \"participants\": \"\",\r\n"
                + "            \"passType\": \"\",\r\n"
                + "            \"previousActivityCode\": \"想玩游戏\",\r\n"
                + "            \"previousActivityID\": \"A-ManyRoute-001\",\r\n"
                + "            \"previousActivityName\": \"想玩游戏\",\r\n"
                + "            \"previousOperateTypeID\": \"RT002\",\r\n"
                + "            \"previousProcessID\": \"XFB0432B54C8D64C2E8BE59CB64F4DC5FF\",\r\n"
                + "            \"processID\": \"XFD52585EAB0004138AAF4E4F3CC61089A\",\r\n"
                + "            \"processNo\": \"-1\",\r\n"
                + "            \"serviceDataID\": \"能玩游戏吗011\",\r\n"
                + "            \"splitProcessID\": \"XFB0432B54C8D64C2E8BE59CB64F4DC5FF\",\r\n"
                + "            \"summary\": \"50.0\",\r\n"
                + "            \"summaryPass\": \"100.0\",\r\n"
                + "            \"templateID\": \"\",\r\n"
                + "            \"workID\": \"XF860BE5B05F064B8CBDC22F747BF2F757\"\r\n"
                + "        },\r\n"
                + "        {\r\n"
                + "            \"counter\": \"1\",\r\n"
                + "            \"counterPass\": \"2\",\r\n"
                + "            \"createOrg\": \"\",\r\n"
                + "            \"createOrgID\": \"\",\r\n"
                + "            \"createTime\": \"2019-09-19 10:56:39\",\r\n"
                + "            \"creater\": \"小明\",\r\n"
                + "            \"createrID\": \"Children-01\",\r\n"
                + "            \"currentActivityCode\": \"爸爸是否同意\",\r\n"
                + "            \"currentActivityID\": \"A-ManyRoute-002\",\r\n"
                + "            \"currentActivityName\": \"爸爸是否同意\",\r\n"
                + "            \"futureParticipants\": \"\",\r\n"
                + "            \"infoComment\": \"要学完英语才能玩\",\r\n"
                + "            \"isPass\": \"\",\r\n"
                + "            \"limitOrgID\": \"\",\r\n"
                + "            \"limitTime\": \"2000-01-01 00:00:00\",\r\n"
                + "            \"limitUserID\": \"\",\r\n"
                + "            \"nextActivityCode\": \"汇总结果\",\r\n"
                + "            \"nextActivityID\": \"A-ManyRoute-004\",\r\n"
                + "            \"nextActivityName\": \"汇总结果\",\r\n"
                + "            \"nextProcessID\": \"XF80D2C26601A14393869330E1C74DE991\",\r\n"
                + "            \"operateDatas\": \"学的快，还有奖励\",\r\n"
                + "            \"operateFiles\": \"这里是英语资料\",\r\n"
                + "            \"operateOrg\": \"\",\r\n"
                + "            \"operateOrgID\": \"\",\r\n"
                + "            \"operateTime\": \"2019-09-19 10:56:53\",\r\n"
                + "            \"operateTimeLen\": \"0\",\r\n"
                + "            \"operateType\": \"汇总\",\r\n"
                + "            \"operateTypeID\": \"RT003\",\r\n"
                + "            \"operateUser\": \"小明的爸爸\",\r\n"
                + "            \"operateUserID\": \"Father-01\",\r\n"
                + "            \"participants\": \"\",\r\n"
                + "            \"passType\": \"\",\r\n"
                + "            \"previousActivityCode\": \"想玩游戏\",\r\n"
                + "            \"previousActivityID\": \"A-ManyRoute-001\",\r\n"
                + "            \"previousActivityName\": \"想玩游戏\",\r\n"
                + "            \"previousOperateTypeID\": \"RT002\",\r\n"
                + "            \"previousProcessID\": \"XFB0432B54C8D64C2E8BE59CB64F4DC5FF\",\r\n"
                + "            \"processID\": \"XF2BB9A3E5F7AF456EB5F0E721E79F58EB\",\r\n"
                + "            \"processNo\": \"-1\",\r\n"
                + "            \"serviceDataID\": \"能玩游戏吗011\",\r\n"
                + "            \"splitProcessID\": \"XFB0432B54C8D64C2E8BE59CB64F4DC5FF\",\r\n"
                + "            \"summary\": \"50.0\",\r\n"
                + "            \"summaryPass\": \"100.0\",\r\n"
                + "            \"templateID\": \"\",\r\n"
                + "            \"workID\": \"XF860BE5B05F064B8CBDC22F747BF2F757\"\r\n"
                + "        }]\r\n"
                + "    },\r\n"
                + "    \"encry\": \"\",\r\n"
                + "    \"format\": \"\",\r\n"
                + "    \"rc\": \"0\",\r\n"
                + "    \"result\": \"true\",\r\n"
                + "    \"ri\": \"\",\r\n"
                + "    \"serialNo\": \"2019091911440552137594XFlowWeb\",\r\n"
                + "    \"session\": \"\",\r\n"
                + "    \"sid\": \"I002QueryNextRoutes\",\r\n"
                + "    \"sidv\": \"\",\r\n"
                + "    \"sign\": \"\",\r\n"
                + "    \"sysid\": \"xx\",\r\n"
                + "    \"tokenSec\": \"\"\r\n"
                + "}";
        v_Object  = (NextRoutes) v_XJson.toJava(v_JsonStr ,"body" ,NextRoutes.class);
        
        $Logger.info(v_Object);
    }
    
    
    @Test
    public void test_JsonToJava_20240607() throws Exception
    {
        XJSON      v_XJson   = new XJSON();
        String     v_JsonStr = "";
        NextRoutes v_Object = null;
        
        v_JsonStr = """
                    {
                        "body": {
                                    "objectType": 2,
                                    "objectTypeEnum": 1
                            }
                    }
                    """;
        v_Object = (NextRoutes) v_XJson.toJava(v_JsonStr ,"body" ,UserParticipant.class);
        
        System.out.println(v_Object.getCurrentProcess().getParticipants().get(0).getObjectType());
        System.out.println(v_Object);
    }
    
}
